<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html>
<head>
    <title>书籍列表</title>

<%--    引用样式--%>
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

</head>
<script>
    function bbb(id) {
        let mes=confirm("您确定要删除吗？");
        if(mes==true){
            window.location.href  = "${pageContext.request.contextPath}/book/delBook/"+id;
        }
        return;
    }
</script>
<style>
    body{

        /*background-image: url("WEB-INF/JSP/mjxy.jpg");*/
    }
</style>

<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1 align="center">
                    <small>书籍管理 </small>
                </h1>
            </div>
        </div>

        <div class="row">
            <div class="col-md-4 column">
                <a class="btn btn-primary" href="${pageContext.request.contextPath}/book/toAddBook">添加书籍</a>

            </div>
            <div class="col-md-2 column">
                <a class="btn btn-primary" href="${pageContext.request.contextPath}/book/list">全部书籍</a>

            </div>

            <form action="${pageContext.request.contextPath}/book/queryBook" method="post"  class="form-inline">
            <div class="col-md-2 column">
                <select class="form-control" style="float: right" name="sel">
                    <option value="0">请选择分类</option>
                    <c:forEach var="category" items="${category}">
                        <option value="${category.id}" ${category.id eq selectCategory?"selected":""}>${category.category}</option>
                    </c:forEach>
                </select>
            </div>
            <div class="col-md-4 column">
                    <input type="text" name="queryBookName" placeholder="请输入要查询的书籍名称" class="form-control"/>
                    <input type="submit" value="查询" class="btn btn-success">
            </div>
            </form>
        </div>
    </div>

    <div class="row clearfix">
        <div class="col-md-12 column">
            <table class="table table-hover table-striped">
                <thead>
                <tr>
                    <th>书籍编号</th>
                    <th>书籍名称</th>
                    <th>书籍数量</th>
                    <th>书籍分类</th>
                    <th>书籍详情</th>
                    <th>操作</th>
                </tr>
                </thead>

                <tbody>
                <c:forEach var="book" items="${books}">
                    <tr>
                        <td>${book.bookID}</td>
                        <td>${book.bookName}</td>
                        <td>${book.bookCounts}</td>
                        <td>${book.category.category}</td>
                        <td>${book.detail}</td>


                        <td>
                            <a href="${pageContext.request.contextPath}/book/toUpdateBook?id=${book.bookID}">修改</a>
                            &nbsp;|&nbsp;
                            <a onclick="bbb(${book.bookID})">删除</a>
<%--                            ${pageContext.request.contextPath}/book/delBook/${book.bookID}--%>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>

</div>

</body>
</html>
